package com.shigu.admin.manager.services;

import com.opentae.data.mall.beans.SystemOem;
import com.opentae.data.mall.examples.SystemOemExample;
import com.opentae.data.mall.interfaces.SystemOemMapper;
import com.shigu.admin.manager.vo.OemVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class OemSystemService {

    @Autowired
    SystemOemMapper systemOemMapper;
    /**
     * 查询系统公告
     * @return
     */
    @Cacheable(value = "selOemByDomain_cach",key = "#domain")
    public OemVO selOemByDomain(String domain){
        OemVO vo=new OemVO();
        SystemOemExample example=new SystemOemExample();
        example.createCriteria().andDomainEqualTo(domain);
        List<SystemOem> oems=systemOemMapper.selectByExample(example);
        if (oems.size()>0) {
            SystemOem oem=oems.get(0);
            vo.setDomain(oem.getDomain());
            vo.setOemFlag(oem.getOemFlag());
            vo.setWxAppId(oem.getWxAppId());
            vo.setWxSecret(oem.getWxSecret());
            vo.setWxQunfa(oem.getWxQunfa());
            vo.setWxTongzi(oem.getWxTongzi());
            return vo;
        }
        vo.setOemFlag("default");
        vo.setDomain(domain);
        return vo;
    }

}
